<%@page import="com.wanmait.hotelManage.vo.Pager"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="com.wanmait.hotelManage.vo.Register"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    String path=request.getContextPath();
    List<Register>registers=(List<Register>)request.getAttribute("register");
    Integer ids=(Integer)request.getAttribute("id");
    %>
<jsp:include page="/manage/inc/header.jsp"></jsp:include>
<jsp:include page="/manage/inc/menu.jsp"></jsp:include>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="<%=path%>/manage/index.jsp">首页</a><span class="crumb-step">&gt;</span><a href="<%=path%>/manage/RoomServlet?action=list">客房管理</a><span class="crumb-step">&gt;</span><span class="crumb-name">客房管理显示信息</span></div>
        </div>
        <div class="result-wrap">
            <form name="myform" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                    </div>
                </div>
                <div class="result-content">
                <div id="pagediv">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th>排序</th>
                            <th>ID</th>
                            <th>名字</th>
                            <th>性别</th>
                            <th>电话</th>
                            <th>身份证号</th>
                            <th>开始时间</th>
                            <th>退房时间</th>
                        </tr>
                        <%
                        if(registers!=null){
                        	DateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                         for(int i=0;i<registers.size();i++){
                        	 Register register=registers.get(i);
                        	 String startTime=df.format(register.getStartTime());
                         	 String endTime=df.format(register.getEndTime());
                         	 %>
                         	  <tr>
                            <td><%=i+1 %></td>
                            <td><%=register.getId() %></td>
                            <td><%=register.getName() %></td>
                            <td><span class="gender"><%=register.getGender() %></span></td>
                            <td><%=register.getTelephoneNumber() %></td>
                            <td><%=register.getIdCard() %></td>
                            <td><%=startTime %></td>
                            <td><%=endTime %></td>
                        </tr>
                         	 <%
                         }   
                        }
                        %>
                    </table>
                    <div class="qwe">
                     <%
                     Pager pager=(Pager)request.getAttribute("pager");
                     if(pager!=null){
                     	 int start= 1;
                          int end =pager.getPageCount();
                          if(pager.getPageCount()>5){
                         	 start=pager.getPageNo()-2<1?1:pager.getPageNo()-2;
                         	 end=start+4;
                         	 if(end>pager.getPageCount()){
                         		 end=pager.getPageCount();
                         		 start=end-4;
                         	 }
                          }
                          %>
                          [<a class="ok" href="javascript:void(0)">上一页</a>]
                          <%
                     	for(int i=start;i<=end;i++){
                     		%>
                     		[<a class="number" href="javascript:void(0)"><%=i %></a>]
                     		<%
                     	}
                          %>
                          [<a class="no" href="javascript:void(0)">下一页</a>]
                          <%
                     }
                     %>
                    </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
<jsp:include page="/manage/inc/footer.jsp"></jsp:include>
<script>
$(function(){
	$(".gender").each(function(){
		var check=$(this).html();
		
		if(check=="false"){
			$(this).html("女");
		}else if(check=="true"){
			$(this).html("男");
		} 
	})
	/* $(".breakfast").each(function(){
		var check=$(this).html();
		
		if(check=="false"){
			$(this).html("不需要");
		}else if(check=="true"){
			$(this).html("需要");
		} 
	}) */
	$(".no").click(function(){
		/* $(".number").css("color","black");
		$(this).css("color","red"); */
		var content=<%=pager.getPageNo()%>;
		if(content<<%=pager.getPageCount()%>){
			content++;
		}
		$.ajax({
			url:"<%=path%>/manage/RoomServlet?action=checkinInformationTwo&id=<%=ids%>",
				data:{pageNo:content},
					success:function(msg){
						$("#pagediv").html(msg);
					}
		})
	})
$(".ok").click(function(){
/* $(".number").css("color","black");
$(this).css("color","red"); */
var content=<%=pager.getPageNo()%>;
if(content>1){
	content--;
}
$.ajax({
url:"<%=path%>/manage/RoomServlet?action=checkinInformationTwo&id=<%=ids%>",
data:{pageNo:content},
success:function(msg){
	$("#pagediv").html(msg);
}
})
})
		$(".number").click(function(){
		var content=$(this).html();
		$.ajax({
			url:"<%=path%>/manage/RoomServlet?action=checkinInformationTwo&id=<%=ids%>",
			data:{pageNo:content},
			success:function(msg){
				$("#pagediv").html(msg);
			}
		})
		
	})
})
</script>
<style>
.qwe{
text-align:center;
}
</style>